package com.zzmemg.test_flutter

import android.content.Context
import android.graphics.Color
import android.util.Log
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import io.flutter.plugin.common.BinaryMessenger
import io.flutter.plugin.platform.PlatformView

class MyFlutterView(context: Context) : PlatformView {

    private val textView: TextView = TextView(context)

    init {
        textView.text = "I from Android, I am TextView"
    }

    override fun getView(): View {
        Log.i("TAG", "====get android TextView")
//        textView.layoutParams = ViewGroup.LayoutParams(200, 200)
//        textView.setBackgroundColor(Color.RED)
        return textView
    }

    override fun dispose() {
        //释放此View时调用，此方法调用后View不可用，此方法需要清除所有对象引用，
        //否则会造成内存泄漏
        Log.i("TAG", "====dispose android TextView")

    }

}